public class Main {
    public static void main(String[] args) {
        String s = "sadbutsad";
        String s1 = "sad";
        int n = strStr(s,s1);
        System.out.println(n);
    }
    public static int strStr(String haystack, String needle) {
        for (int i = 0; i < haystack.length()-1; i++) {
            if(haystack.charAt(i) == needle.charAt(0)) {
                int j = i;
                for (; j-i < needle.length()-1;) {
                    if(haystack.charAt(j) == needle.charAt(j-i)) {
                        j++;
                    } else {
                        break;
                    }
                }
                if(j-i == needle.length()-2) {
                    return i;
                }
            }
        }
        return -1;
    }
}
